home *** CD-ROM | disk | FTP | other *** search
/ DC Comics 2.0 / DC Collected Edi.iso / pc / collect / functions.js < prev    next >
Text File  |  2002-08-29  |  3KB  |  71 lines

  1. //************************************************************
  2. // This example is from JavaScript: The Definitive Guide, 3rd Edition.
  3. // That book and this example were Written by David Flanagan.
  4. // They are Copyright (c) 1996, 1997, 1998 O'Reilly & Associates.
  5. // This example is provided WITHOUT WARRANTY either expressed or implied.
  6. // You may study, use, modify, and distribute it for any purpose,
  7. // as long as this notice is retained.
  8. //<!-- Modified by:  Kenneth C. Devoe, WildStorm Productions -->
  9. /*
  10.  * Function getArgs() parses comma-separated name=value argument pairs from
  11.  * the query string of the URL. It stores the name=value pairs in 
  12.  * properties of an object and returns that object.
  13.  */
  14. function getArgs() {
  15.     var args = new Object();                   // Create the object.
  16.     var query = location.search.substring(1);  // Get query string.
  17.     var pairs = query.split("&");              // Break at ampersand.
  18.     for(var i = 0; i < pairs.length; i++) {
  19.     var pos = pairs[i].indexOf('=');           // Look for "name=value".
  20.     if (pos == -1){
  21.      continue;                                 // If not found, skip.
  22.     }
  23.     var argname = pairs[i].substring(0,pos);  // Extract the name.
  24.     var value = pairs[i].substring(pos+1);    // Extract the value.
  25.     args[argname] = unescape(value);          // Store as a property.
  26.     }
  27.     return args;                              // Return the object.
  28. }
  29.  
  30. /*
  31.  * Function myVoid() does nothing.  It is used when the anchor tag has an event
  32.  * such as OnMouseOver that uses a function.  We want the function to be called
  33.  * rather than the URL in the anchor tag called.
  34.  */
  35. function myVoid(){}
  36.  
  37. /*
  38.  * Function popUpPage( page2, page, name, scroll) opens an html file in a 
  39.  * new browser window and centers the window on the user's computer screen.
  40.  * This function is passed to it:
  41.  * page2 - the URL of the HTML page to open.
  42.  * page - the page type eg. cvr, p1, p2, p3.
  43.  * name - the name to give the browser window.
  44.  * scroll - the option of scroll bars on the browser window, yes or no.
  45. */
  46. function popUpPage( page2, page, name, scroll) {
  47. var h = (750); // height of the popup page.
  48. var w = (480); // width of the popup page.
  49. var win2X = (screen.width/2 - w/2); // Center popup page offset by it's width.
  50. var win2Y = 30; // Top of the popup page on the screen.
  51. winprops2 = 'height='+h+',width='+w+',top='+win2Y+',left='+win2X+',scrollbars='+scroll+',resizable'// properties of the browser window.
  52. page2 = page2 +"?itemCode="+itemCode[index]+"&itemIssue="+itemIssue[index]+"&page="+page // addition of name=value pairs to URL.
  53. win2 = window.open(page2, name, winprops2) // Opens the new browser window.
  54. if (parseInt(navigator.appVersion) >= 4) { win2.window.focus(); } // Give the new browser widow focus.
  55. }
  56.  
  57. /*
  58.  * Function update_frame(myoptions) opens a new web page in the current browser widow.
  59.  * It is used by selecting an oprion on the drop down navigation forms.
  60.  * This function is passed to it:
  61.  * myoptions - object containing the URL of the HTML page to open.
  62.  */
  63. function update_frame(myoptions) {
  64.     destination=myoptions[myoptions.selectedIndex].value;
  65.     if(destination=="null"){
  66.         return true; 
  67.     }
  68.     window.open(destination, '_self'); // Opens the new browser window.
  69.     myoptions.selectedIndex=0; 
  70.     return true;
  71. }